package com.ylz.sjzx.sio.core.group.manager;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * IM本机监控
 *
 * @author
 * @version 1.0
 * @date 2021/1/11
 */
@Component
@Slf4j
public class RpcMonitor {


    @Scheduled(cron = "0/30 * * * * ? ")
    public void remotingClientMapInfo() {
        log.info("=========当前IM服务一共有{}个服务端连接====", GroupRpc.serviceAddr.size());
        GroupRpc.serviceAddr.forEach((k, v) -> {
            log.info("=========服务端IP={}====", k);
        });
    }

    /**
     * 主动获取服务 防止只是channel断开 而服务器不停止的场景
     */
    @Scheduled(cron = "0 0/1 * * * ? ")
    public void autoDiscoverIm() {
        DiscoverManager.refreshService();
    }

}
